package liujia.bt.display.base
{
	import liujia.bt.display.core.BtRun;
	
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	
	/**
	 * BtCanvasChild
	 * @author 刘佳 liujia08@snda.com
	 * $Id: BtCanvasChild.as 2 2011-10-31 01:46:19Z sigmaliu@163.com $
	 * @version 1.0
	 */
	public class BtCanvasChild extends BtAnim
	{
		internal var sourceRect:Rectangle = new Rectangle();
		
		internal var destPoint:Point = new Point();
		
		internal var bitmapdata:BitmapData;
		
		public function BtCanvasChild(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false)
		{
			super(bitmapData, pixelSnapping, smoothing);
		}
		
		override public function enterFrame():void {
			if (!_isPlaying) return;
			if (BtRun.nowTime - oldTime >= _ms) {
				oldTime = BtRun.nowTime;
			} else {
				return;
			}
			if (++_currentFrame > _totalFrames) _currentFrame = 1;
			
			_currentBtFrame = _btFrameVec[_currentFrame-1];
			_rect = _currentBtFrame.rect;
			updateXY();
			
			bitmapdata = _currentBtFrame.bitmapData;
			sourceRect.width = _rect.width;
			sourceRect.height = _rect.height;
			destPoint.x = superX;
			destPoint.y = superY;
			
			if (isPlayOnce && (currentFrame==totalFrames)) {
				stop();
			}
		}
	}
}
